﻿using System;
using System.Windows;
using ClientWPF.BankService;
using DevExpress.Xpf.Core;

namespace ClientWPF
{
    /// <summary>
    /// Interaction logic for StatusPopup.xaml
    /// </summary>
    public partial class StatusPopup
    {
        private readonly BankServiceClient bankServiceClient;

        public StatusPopup()
        {
            InitializeComponent();
            bankServiceClient = new BankServiceClient();
        }

        private void BtnGetStatusClick(object sender, RoutedEventArgs e)
        {
            if (tbPaymentOrderNumber.Text.Length == 0)
            {
                DXMessageBox.Show("Введите номер платёжного поручения", "Ошибка",
                                     MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                Guid g;
                if (Guid.TryParse(tbPaymentOrderNumber.Text, out g))
                {
                    State st = bankServiceClient.GetPaymentOrderState(g);
                    lblStatus.Content = st != null ? st.TransactionState : "не найдено";

                    /*
                  banks = new ObservableCollection<Bank>(bankServiceClient.GetBanksList());
                  List<PaymentOrder> paymentOrders = new ObservableCollection<PaymentOrder>(bankServiceClient.GetClientDeposits(idClient));
                    */
                }
                else
                {
                    DXMessageBox.Show("Введён некорректный номер. Пожалуйста, введите корректный номер.", "Ошибка",
                                       MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }

        private void ButtonCloseClick(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }
}